<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>

    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected" style="width: 10%;">序号</th>
                <th class="">内容</th>
                <th class="">学习内容</th>
                <th class="">教学重点</th>
                <th class="">课后作业</th>
                <th class="">时间</th>
                <th class="">授课老师</th>
                <th class="" style="width: 44px;">操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td>{$i}</td>
                        <td>{$vo.content}</td>
                        <td>{$vo.teach_plan}</td>
                        <td>{$vo.teach_situation}</td>
                        <td>{$vo.homework}</td>
                        <td><input type="text" class="text" id="class_time_{$vo.id}" style="width: 120px;" name="class_time[]" value="{$vo.class_time|time_format}"  <eq name="vo.step" value="3">disabled</eq> ></td>
                        <td>
                            <select name="teacher_{$vo.id}" id="teacher_{$vo.id}" style="width: 100px;" onchange="_saveData({$vo.id})" <eq name="vo.step" value="3">disabled</eq>>
                                <volist name="_teacher" id="tea" key="k">
                                    <option value="{$tea.uid}" <php>if($tea['uid']==$vo['teacher_id'])echo 'selected="selected"';</php> >{$tea.nickname}</option>
                                </volist>
                            </select>
                        </td>
                        <td>

                            <switch name="vo.step">
                                <case value="1"><a href="{:U('lesson?id='.$vo['id'])}" class="authorize">备课</a></case>
                                <case value="2"><a href="{:U('complete?id='.$vo['id'])}" class="authorize" style="color: #A0522D;">完成</a></case>
                                <case value="3"><a href="{:U('complete?ck=1&id='.$vo['id'])}" class="authorize" style="color: #DB7093;">回访</a></case>
                                <default /><a href="{:U('complete?ck=1&id='.$vo['id'])}" class="authorize" style="color: #999999;">已回访</a>
                            </switch>
                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="14" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">

        <volist name="_list" id="vo">
        laydate.render({
            elem: '#class_time_{$vo.id}' ,
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm',//可任意组合
            done: function(value, date){ //监听日期被切换
                document.getElementById("class_time_{$vo.id}").value = value;
                _saveData({$vo.id});
            }
        });
        </volist>

        function _saveData(id) {
            var class_time = $("#class_time_"+id).val();
            var teacher = $("#teacher_"+id).val();
            $.ajax({
                type: 'POST',
                url: "{:U('ajaxSaveData')}",
                data: "id="+id+"&class_time="+class_time+"&teacher="+teacher,
                success: function (res) {
                    if(res.status==1){
                    }else{
                        updateAlert('服务器繁忙，请重试!');
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                        },2000);
                    }
                }
            });
        }

        //导航高亮
        highlight_subnav('{:U('Teaching/index')}');
    </script>
</block>
